﻿/// <reference path="../../Scripts/jquery-1.7.1-vsdoc.js" />
/// <reference path="../Common.js" />

$(function () {
    $("#Conversation").live("click", function () {
        userinfo.showmsg();
    })
})

var userinfo = {

    showmsg: function () {

        $("#Content").live("blur", function () {
            var Content = $("#Content").val();
            if (Content == "请输入私信内容" || Content == "")
            {
                $("#Content").val('请输入私信内容');
            }
        }).live("focus", function () {
            var Content = $("#Content").val();
            if (Content == "请输入私信内容")
            {
                $("#Content").val('');
            }
        })

        var htmlstr = $("#ContentDiv").html();
        $.dialog({
            content: htmlstr,
            ok: function () {
                userinfo.addmsg();
                return true;
            },
            cancelVal: '关闭',
            cancel: true /*为true等价于function(){}*/
        });
    },

    addmsg: function () {
        //定义模型对象
        var pl = {};
        //模型的字段属性赋值
        pl.Incept = $("#NickName").val();
        pl.InceptUserID = $("#UserID").val();
        pl.Conversation = $("#Content").val();

        $.ajax ({
            url: "/UserAPI/AddMsg",
            type: "post",
            //发送模型对象的类型
            dataType: "json",
            data: JSON.stringify(pl),
            contentType: "application/json; charset=utf8",
            success: function (data) {
                if (data > 0) {
                    alert("发送成功");
                } else alert("发生失败");
            }
        })

    }

}